#ifndef FILESELECTOR_H
#define FILESELECTOR_H

#include <QWidget>
#include <Maestro/mcplugins.h>
#include <Maestro/database.h>
#include "button.h"
#include "keycontrollablemenu.h"
#include "playermanager.h"
#include "mediachecker.h"
#include "popupmenu.h"
#include "dropdownbutton.h"
#include "propertiesdialog.h"
#include "playlistselectiondialog.h"


/**
  * The file selector provides a means of searching through and sorting files and selecting them.
  */
namespace Ui {
    class FileSelector;
}

class FileSelector : public KeyControllableMenu {
    Q_OBJECT
public:
    FileSelector(QWidget *parent = 0, FileSelectionInterface * interface =0);
    ~FileSelector();
    void reloadFiles(QString playlistName = "");
    void showFiles(int startIndex);
    void setCurrent(int current);  
    void setFilter(QString filter);
public slots:
    void buttonSelected();
    void buttonEntered(Button *button);
    void show();
    void buttonRightClicked();
    void keyPressEvent ( QKeyEvent * event );
    void propertiesModified(MediaFile *);
    void addCurrentMediaToPlaylist(QString *);
    void removeCurrentMediaFromPlaylist();
    void hide();
    void addAndRemoveButtons();
private slots:
    void on_downButton_clicked();
    void on_upButton_clicked();
    void buttonSelected(Button * button);
private:
    Ui::FileSelector *ui;
    void addFile(MediaFile * file);
    QList<MediaFile *>* files;
    QList<MediaFile *>* filteredFiles;
    FileSelectionInterface * interface;
    int current;
    QList<Button *> * buttons;
    QWidget * player;
    QString filter;
    QString playlistName;
    PopupMenu * popup;
    Button * favouriteButton;
    Button * addToPlaylistButton;
    Button * removeFromPlaylistButton;
    Button * propertiesButton;
    Button * coverArtButton;
    Button * cancelButton;
    QVBoxLayout * playerLayout;
    DropDownButton * sortByButton;
    Button * nameSort;
    Button * dateSort;
    int itemsPerPage;
    PropertiesDialog * propertiesDialog;
    PlaylistSelectionDialog * playlistSelectionDialog;
    MediaChecker * checker;

};

#endif // FILESELECTOR_H
